<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateAdminsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admins', function (Blueprint $table) {
            $table->increments('id')->comment('管理员ID');
            $table->string('username',30)->comment('管理员用户名');
            $table->string('password',100)->comment('管理员密码');
            $table->string('loginip',40)->nullable(true)->comment('登录IP');
            $table->string('ipadress',50)->nullable(true)->comment('登录IP详细地址');
            $table->integer('logintime')->nullable(true)->comment('上次登录时间');
            $table->integer('loginnum')->nullable(true)->comment('登录次数');
            $table->string('ip',40)->nullable(true)->comment('注册IP');
            $table->integer('addtime')->comment('添加时间');
            $table->tinyInteger('is_open')->default(1)->comment('状态;0禁止;1启用');
            $table->string('avatar',120)->nullable(true)->comment('头像');
            $table->mediumInteger('group_id')->nullable(true)->comment('分组ID');
        });
        $prefix = DB::getConfig('prefix');
        DB::statement("ALTER TABLE `{$prefix}admins` comment '管理员表'"); // 表注释
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admins');
    }
}
